package OOAE_UWE.Assessment;

public class Room {
    private String roomNumber;
    private String type;
    private State currentState;
    private boolean isRented; // if rented or not

    public Room(String roomNumber, String type, State initialState) {
        this.roomNumber = roomNumber;
        this.type = type;
        this.currentState = initialState;
        this.isRented = false; // no rented
    }

    public void setState(State newState) {
        if (currentState.equals(newState)) {
            System.out.println("Room " + roomNumber + " is already in state: " + newState);
        } else if (currentState.canSwitch(newState)) {
            currentState = newState;
            System.out.println("Room " + roomNumber + " state changed to: " + newState);
        } else {
            throw new IllegalStateException("Illegal conversion: " + currentState + " → " + newState);
        }
    }

    public boolean isAvailableForRent() {
        return !isRented && currentState.isAvailableForRent();
    }

    public State getCurrentState() {
        return currentState;
    }

    public String getRoomNumber() {
        return roomNumber;
    }

    public boolean isRented() {
        return isRented;
    }

    public void setRented(boolean rented) {
        isRented = rented;
    }
}